use std::collections::HashSet;

use libp2p::{
    core::transport::ListenerId, kad, request_response::ResponseChannel, Multiaddr, PeerId,
};
use tokio::sync::oneshot;

use crate::p2p::types::common::TResult;

use super::file_share::FileResponse;

#[derive(Debug)]
pub enum Command {
    StartListening {
        addr: Multiaddr,
        sender: oneshot::Sender<TResult>,
    },
    RemoveListener {
        listener_id: ListenerId,
        sender: oneshot::Sender<TResult>,
    },
    Dial {
        peer_id: PeerId,
        peer_addr: Multiaddr,
        sender: oneshot::Sender<TResult>,
    },
    StartProviding {
        file_name: String,
        sender: oneshot::Sender<()>,
    },
    GetProviders {
        file_name: String,
        sender: oneshot::Sender<HashSet<PeerId>>,
    },
    RequestFile {
        file_name: String,
        peer: PeerId,
        sender: oneshot::Sender<TResult<Vec<u8>>>,
    },
    RespondFile {
        file: Vec<u8>,
        channel: ResponseChannel<FileResponse>,
    },
    SetKadMode {
        mode: Option<kad::Mode>,
        sender: oneshot::Sender<()>,
    },
    Stop {
        sender: oneshot::Sender<TResult>,
    },
}
